package ttestClosed;

import java.util.Queue;
import java.util.concurrent.DelayQueue;

public class TestDelayQueue {

	private Queue<TestFrame> queue;

	public Queue<TestFrame> getQueue() {
		return queue;
	}

	public void setQueue(Queue<TestFrame> queue) {
		this.queue = queue;
	}

	public TestDelayQueue() {
		super();
		this.queue = new DelayQueue<TestFrame>();
	}
	
	public void addFrame(TestFrame frame) {
		queue.add(frame);
		
	}
	
	public TestFrame getHead() {
		return this.queue.poll();
	}
	
	public static void main(String[] args) {
		TestDelayQueue tdq = new TestDelayQueue();
		tdq.addFrame(new TestFrame(1000, "Here it is!"));
		System.out.println("START IT!");
		long delay = System.currentTimeMillis();
		while (System.currentTimeMillis() - (delay + 1001) < 0) {
			TestFrame frame = tdq.getHead();
			System.out.println(frame);
			if(frame != null) {
				System.out.println(frame.getData());
			}
		}
	}
	
}
